//
//  GeneralViewController.swift
//  SwiftStudy
//
//  Created by wangtian on 15/7/14.
//  Copyright (c) 2015年 wangtian. All rights reserved.
//

import UIKit

class GeneralViewController: UIViewController {

    
    var sArray:[AnyObject]?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.setUpView()
        self.doSomeThingForTest()
        // Do any additional setup after loading the view.
    }

    //设置view
    func setUpView(){
    
        self.title = "基础语法学习"
    }
    
    func doSomeThingForTest(){
    
//        self.kongzhiyuju_for()
//        self.xiabiao()
//        singleTest()
//        classTest()
//       print("123")
        changliangbianliang()
        self.canSelectBind()
    }
    
    //MARK: 可选绑定
    func canSelectBind()
    {
        var a : String?
        if let b = a
        {
            print(b)
        }
        a = String(2)
        if let c = a
        {
            print("c is \(c)")
        }
    }
    
    //逻辑控制语句
    func kongzhiyuju_for(){
    
        var strArray = ["a","b","c","d"]
//        for i in 0 ... (strArray.count += 1){
//        
//            print("\(strArray[i])")
//        }
        
        for _ in 1...strArray.count{
        
            print("...")
        }
        
        for str in strArray{
        
            print("\(str)")
        }
        
        for (index,value) in strArray.enumerated(){
        
            print("index = \(index) value = \(value)")
        }
    }
    
    //MARK: 下标
    func xiabiao(){
    
        print(12[3])
    }
    
    //MARK: 单例测试
    func singleTest()
    {
        var a = "12"

//        let single: AnyObject = MySIngleClass.shareInstance()
//        if single.isMember(of: single.classNamed("SingleClass")!)
//        {
//            print("single isMemberOfclass SingleClass")
//        }
//        if single.isMember(of: single.classNamed("SingleClass")!)
//        {
//            print("single isMemberOfclass MySIngleClass")
//        }
//        print(single)
    }
    
    //MARK: 类、枚举、结构体
    func classTest()
    {
        let myClass:MyClass = true
        print("=======\(myClass.cProperty!)")
        //myClass.b = "test"
        
        let myClass1:MyClass = MyClass()
        myClass1[0] = "ssss"
        print("=======\(myClass1.cProperty!)")
        
        let myClass3 = myClass + myClass1
        print("\(myClass3.cProperty)")
        
        //println("\(myClass[0])")
//
//        var myEnum:Myenum = Myenum.four("four")
//        print(myEnum)
//        
//        var myEnum1:Myenum = Myenum(initfour: "four")
//        print(myEnum1)
    }
    
    func changliangbianliang(){
    
        let twoThousand: UInt16 = 2_00_0
        print("++++++++++++\(twoThousand)")
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
